package model;

/*****************************************
 * log
 * 
 * Holds information about a particular log in the game
 * 
 * @author Stephen Gregory, Jun Wang
 *
 */

public class log {
	private int posX;
	private int posY;
	private int velocityX;
	private int point;
	private int height; 
	private int width;
	private String word;
	public static final int BLUE = 0;
    public static final int ORANGE = 1;
    public static final int PINK = 3;
    public static final int GREEN = 2;
    public static final int RED = 4;
    int type;
	
	/**
	 * Constructor: log
	 * Purpose: associate a word with a log and a point value
	 */
	
	public log(String word) {
		this.word = word;
		this.point = 10 * word.length(); //set point value based on word length
		this.velocityX = 0;
		this.type = 0;
	}
	
	public void setType(int i) {
		type = i;		
	}
	
	public int getType() {
		return type;
	}


	
	/**
	 * Method: move
	 * Purpose: change the position of the log
	 */
	
	public void move(int time) {
		//if the log is moving left (or right) and it has passed
		//the edge of the screen, reset the position
		//so that it appears to "wrap around"
		if (posX < -100 && velocityX < 0) {
			posX = 1000;
		}
		else if (posX >= 1100 && velocityX > 0) {
			posX = -100;
		}
		else		
			posX += velocityX * time;
	}
	
	/**
	 * Method: setDim
	 * Purpose: set the width and height of the log
	 */
	
	public void setDim(int w, int h) {
		this.width = w;
		this.height = h;
	}
	
	/**
	 * Method: setPos
	 * Purpose: set the position of the log
	 */
	
	public void setPos(int x, int y) {
		this.posX = x;
		this.posY = y;
	}
	
	public void setVelocityX(int vx) {
		this.velocityX = vx;
	}
	
	public int getVelocityX() {
		return velocityX;
	}
	
	public String getWord() {
		return word;
	}
	
	public int getPosX() {
		return posX;
	}
	
	public int getPosY() {
		return posY;
	}
	
	public int getHeight() {
		return height;
	}
	
	public int getWidth() {
		return width;
	}
	
	public int getPointValue() {
		return point;
	}
	
	public void incVelocityX() {
		if (velocityX < 0)
			--velocityX;
		else
			++velocityX;		
	}

	public void decVelocityX() {
		if (velocityX < 0)
			++velocityX;
		else
			--velocityX;	
	}


}
